home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / pao / pvs_pvd / src / retry.asm < prev    next >
Assembly Source File  |  1994-06-01  |  5KB  |  162 lines

  1. ;==============================================================================
  2. ;    << 386ASM V2.0 >>  for  FM TOWNS
  3. ;==============================================================================
  4. .386p
  5.         PAGE        60,132
  6.         NAME        RETRY
  7.         TITLE        CRITICAL ERROR auto Retry
  8. ;==============================================================================
  9. ;    致命的エラー回避処理(CTRL+Cマスク処理)
  10. ;
  11. ;    CREATE : 1990.06.01
  12. ;    FINISH : 1990.06.02
  13. ;
  14. ;    < High C からの呼出形式 >
  15. ;------------------------------------------------------------------------------
  16. ;    extern void _harderr_clear( void ) ;
  17. ;    extern void _harderr_retry( void ) ;
  18. ;    _harderr_clear() ;
  19. ;    _harderr_retry() ;
  20. ;------------------------------------------------------------------------------
  21. ;
  22. ;    < NOTE > : TABS = 4
  23. ;
  24. ;    < HISTORY >
  25. ;    1990.06.01 : CREATE
  26. ;    1993.08.24 : 致命的エラー処理を自動回避処理とする
  27. ;
  28. ;    < コメント >
  29. ;    ベクタを書き換えた場合には,元に戻しておくべきなのだが,INT23h/INT24hについて
  30. ;    は,DOSがPSPによって元に戻してくれるのでここでは処理していない.
  31. ;
  32. ;    Programmed by Y.Hirata ( Nifty-ID : NAB03321 )
  33. ;==============================================================================
  34. INCLUDE    TOWNS.INC                            ;
  35. ;
  36. CGROUP    GROUP pmcode, CODE                    ;
  37. DGROUP    GROUP pmdata, DATA                    ;
  38. ;
  39. ;--------------------------------------------
  40.         public    _harderr_clear                ; 致命的エラー回数クリア
  41.         public    _harderr_retry                ; 致命的エラー割り込み登録
  42. ;--------------------------------------------
  43. ;
  44. ;////////////////////////////////////////////
  45. ;            ネイティブ部
  46. ;////////////////////////////////////////////
  47. ;********************************************
  48. ;    致命的エラーネイティブハンドラ内での使用データ領域
  49. ;********************************************
  50. DATA    SEGMENT                                ;
  51. rcnt        DW        0                        ; リトライカウンタ
  52. rax            DW        ?                        ;
  53. rcx            DW        ?                        ;
  54. nretry        DW        3                        ; リトライ回数
  55. wtime        DW        100                        ; リトライ時待ち時間
  56. DATA    ENDS                                ;
  57. ;
  58. ;********************************************
  59. ;    致命的エラーハンドラ/ネイティブ処理
  60. ;********************************************
  61. pmcode    SEGMENT                             ;
  62.         ASSUME    cs:CGROUP, ds:DGROUP        ;
  63. ;--------------------------------------------
  64. ;    CTRL+C ネイティブハンドラ
  65. ;--------------------------------------------
  66.         ALIGN    4                            ; dword boundary
  67. INT23_hook    PROC    FAR                        ;
  68.             iretd                            ;
  69. INT23_hook    ENDP                            ;
  70. ;
  71. ;--------------------------------------------
  72. ;    致命的エラーネイティブハンドラ
  73. ;--------------------------------------------
  74.         ALIGN    4                            ; dword boundary
  75. INT24_retry    PROC    FAR                        ;
  76.             cli                                ;
  77.             push    ds                        ;
  78.             push    eax                        ; eax退避
  79.             mov        ax,DATASEG                ; データセグメント設定
  80.             mov        ds,ax                    ;
  81.             pop        eax                        ; eax復元
  82.             mov        rcx,cx                    ; レジスタ退避
  83.             mov        cx,wtime                ;
  84.             int        0FDh                    ; wait
  85.             mov        cx,rcx                    ; レジスタ復元
  86.             mov        ax,rcnt                    ;
  87.             cmp        ax,nretry                ;
  88.             jb        short i24h_retry        ;
  89.             mov        ax,0003h                ; システムコール失敗でリターン
  90.             mov        rcnt,0                    ;
  91.             pop        ds                        ;
  92.             iretd                            ; 割り込み復帰
  93. i24h_retry:                                    ;
  94.             inc        ax                        ;
  95.             mov        rcnt,ax                    ;
  96.             mov        ax,0001h                ; リトライ
  97.             pop        ds                        ;
  98.             iretd                            ; 割り込み復帰
  99. INT24_retry    ENDP                            ;
  100. ;
  101. ;--------------------------------------------
  102. ;    CTRL+C割り込み登録
  103. ;--------------------------------------------
  104.         ALIGN    4                            ; dword boundary
  105. _signal_mask:                                ;
  106.             cli                                ;
  107.             lea        edx,INT23_hook            ;
  108.             mov        cl,23h                    ; CTRL+Cの割り込み番号
  109.             mov        ax,2506h                ; ネイティブハンドラの登録
  110.             sti                                ;
  111.             int        INT_DOS                    ;
  112.             ret                                ;
  113. ;
  114. ;--------------------------------------------
  115. ;    致命的エラー回数クリア
  116. ;--------------------------------------------
  117.         ALIGN    4                            ; dword boundary
  118. _harderr_clear    PROC                        ;
  119.             mov        rcnt,0                    ;
  120.             ret                                ;
  121. _harderr_clear    ENDP                        ;
  122. ;
  123. ;--------------------------------------------
  124. ;    致命的エラー割り込み登録
  125. ;--------------------------------------------
  126.         ALIGN    4                            ; dword boundary
  127. _harderr_retry    PROC                        ;
  128.             push    ebp                        ;
  129.             mov        ebp,esp                    ; スタックフレーム形成
  130. ;
  131.             push    ds                        ;
  132.             push    es                        ;
  133.             push    edx                        ;
  134.             push    ecx                        ;
  135. ;
  136.             push    cs                        ;
  137.             pop        ds                        ; ds = cs
  138. ;
  139.             call    _signal_mask            ; CTRL+Cをマスク
  140. ;
  141.             cli                                ;
  142.             lea        edx,INT24_retry            ;
  143.             mov        cl,24h                    ; 致命的エラーの割り込み番号
  144.             mov        ax,2506h                ; ネイティブハンドラの登録
  145.             sti                                ;
  146.             int        INT_DOS                    ;
  147. ;
  148.             pop        ecx                        ;
  149.             pop        edx                        ;
  150.             pop        es                        ;
  151.             pop        ds                        ;
  152.             xor        eax,eax                    ; return code = 0
  153. ;
  154.             pop        ebp                        ; スタックフレーム開放
  155.             ret                                ;
  156. _harderr_retry    ENDP                        ;
  157. ;
  158. pmcode        ENDS                            ;
  159. ;
  160.         END
  161.  
  162.